cmake_minimum_required(VERSION 3.5)
project(gcs VERSION 1.0.0)

# 查找依赖包
find_package(Qt5 REQUIRED COMPONENTS Widgets Core Network)
find_package(PkgConfig REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(rviz_common REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rviz_custom_plugins REQUIRED)


# 启用自动MOC生成
set(CMAKE_AUTOMOC ON)
set(CMAKE_VERBOSE_MAKEFILE ON)


file(GLOB_RECURSE SOURCE "include/*.h" "src/*.cpp")

# 添加可执行目标
add_executable(${PROJECT_NAME}
  ${SOURCE}
)

# 包含目录配置（关键修改点）
target_include_directories(${PROJECT_NAME} PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include/${PROJECT_NAME}>
  ${Qt5Core_INCLUDE_DIRS}
  ${Qt5Widgets_INCLUDE_DIRS}
)

ament_target_dependencies(${PROJECT_NAME}
  rclcpp
  rviz_common
  Qt5
  rviz_custom_plugins
)

# 链接库
target_link_libraries(${PROJECT_NAME}
  # rclcpp::rclcpp
  # rviz_common::rviz_common
  # Qt5::Core
  # Qt5::Widgets
  # PUBLIC OpenMP::OpenMP_CXX
)


# message(WARNING "rviz_custom_plugins include dirs: ${rviz_custom_plugins_INCLUDE_DIRS}")

# install(DIRECTORY include/
#   DESTINATION include/${PROJECT_NAME}
# )

install(FILES gcs.rviz
  DESTINATION share/${PROJECT_NAME}
)

# 安装规则
install(TARGETS ${PROJECT_NAME}
  RUNTIME DESTINATION bin
)


ament_package()
